<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;

?>
<div class="rightArea">
		<div class="screening_box">
        	<div class="page-header">
    			<h1>与<?php echo $knowid?>相关的资源</h1>
		</div>
                <?php $form= ActiveForm::begin([
//                     'options' => ['class' => 'fl'],
                ])?>
                
                 <?php ActiveForm::end()?>
                 <table width="98%"  border="0"  rules="none" align="center" style="margin-top:5px;">
                        <tr class="form-title">
                          <th>序号</th>
                          <th>资源名称</th>
                          <th>权重</th>
                        </tr>
                        <?php
                        foreach ($data as $value):
                        ?>
                        <tr>
                          <td><?php echo $value->id;?></td>
                          <td><?php echo $value->resource['title']?></td>
                          <td><input class="resweight" type="number" min="0" max="100" step="1" style="width:50px;" value="<?php echo $value->weight?>" onclick="weightchange(<?php echo (string)$value->id?>,this.value)"/></td>
                        </tr>
                        <?php endforeach;?>
                        <tr><td colspan="3">
                            <?php
                            echo yii\widgets\LinkPager::widget(['pagination'=>$pager]);
                          ?>
                            </td></tr>
        		</table>
                    <?php 
                    if(Yii::$app->session->hasFlash('info'))
                    {
                        echo Yii::$app->session->getFlash('info');
                    }
                    ?>
                 
                    <div>
                        
                    </div>
                   
        </div>
</div>

<script type="text/javascript">
    //ajax修改权重
    //请求参数有问题
     function weightchange(id,weight){
         $.ajax({
                type:'POST',
                url:"http://localhost:8089/knowMap/frontend/web/index.php?r=user/weightchange",
                data:JSON.stringify({
                    'id':id,
                    'weight':weight
                }),
                dataType:'json',
                success:function (response,status,xhr) {
                    
                }
        });
    }
    
    
</script>
